#!c:/usr/perl

use strict;
use warnings;
use encoding 'utf8';

#use ContentManager;
use NewContentManager;
use ResultObject;

my $baseUrl = undef;

#odczyt danych z pliku
my $content = '';
#open(FILE, "google.html");
#open(FILE, "google_no_next.html");
open(FILE, "google_3.html");
#open(FILE, "bing.html");
#open(FILE, "netsprint.html");
#open(FILE, "altavista.html");
#open(FILE, "altavista2.html");

while(my $line = <FILE>) {
	$content .= $line;
}
close(FILE);

#wyciagniecie danych
my $contentManager = NewContentManager->new($baseUrl);
$contentManager->configureResultsBoxAttributes('div', 'id', 'search', NewContentManager->BOX_TYPE_UL);
$contentManager->doWork($content);

my $nextPageUrl = $contentManager->getNextPageUrl();
print "   Next page: $nextPageUrl \n\n";

my $resultListRef = $contentManager->getResultList();
my @resultList = @{$resultListRef};
my $i = 0;
foreach my $result (@resultList) {
	print ++$i . ". " . $result->getTitle() . " (" . $result->getUrl() . ")\n";
}
